/**
 * 
 */
package com.gxljc.bear.crawler.itaogao.util;

import org.apache.log4j.Logger;

import com.gxljc.commons.util.Pair;
import com.gxljc.bear.crawler.base.DolphinCrawlerConsts;
import com.gxljc.bear.crawler.base.DolphinFetchData;
import com.gxljc.bear.crawler.itaogao.ItaogaoConst;

/**
* @author haitao E-mail:haitao@summba.com
* @version createTime：2021年9月19日 下午2:24:06
* 匹配网页数据
*/

public class FetchDataUtil {
	private final static Logger LOG = Logger.getLogger(FetchDataUtil.class);

	public static Pair<String, byte[]> fetResult(String url, boolean proxy) {
		try {
			DolphinFetchData fetchData = DolphinFetchData
					.getInstance(DolphinCrawlerConsts.CrawlerChannelType.bear.getName());
			Pair<String, byte[]> pair = fetchData.getResult2Pair(url, proxy, ItaogaoConst.CRAWL_TIMEOUT);
			if (pair == null) {
				LOG.error("page result is empty url = " + url);
				return null;
			}
			return pair;
		} catch (Exception e) {
			LOG.error(String.format("url=%s fetResult error!", url));
		}
		return null;
	}
}
